<?php
/**
 * Created by : Sandi Rizky Kharisma (sandi.informatics08@gmail.com)
 * This Class Generated for CRUD purpose only
 */
class m_info_usaha extends CI_Model
{

    function __construct()
    {
        parent::__construct();
    }

    public function get($where = null, $limit = null, $offset = null)
    {
        if($where != null) $this->db->where($where);
        if($limit != null && $offset != null) $this->db->limit($limit, $offset);
        return $this->db->get("info_usaha");
    }

    function get_all($limit, $uri)
    {

        $result = $this->db->get('info_usaha', $limit, $uri);
        if ($result->num_rows() > 0)
        {
            return $result->result_array();
        } else
        {
            return array();
        }
    }

    function get_one($id)
    {
        $this->db->where('KODE_USAHA', $id);
        $result = $this->db->get('info_usaha');
        if ($result->num_rows() == 1)
        {
            return $result;
        } else
        {
            return array();
        }
    }

    function insert()
    {
        $data = array(

                'KODE_USAHA' => $this->input->post('KODE_USAHA', TRUE),

                'URAIAN_USAHA' => $this->input->post('URAIAN_USAHA', TRUE),

                'MAX_CICIL' => $this->input->post('MAX_CICIL', TRUE),

                'MIN_ANGSURAN' => $this->input->post('MIN_ANGSURAN', TRUE),

                'MAX_PIUTANG' => $this->input->post('MAX_PIUTANG', TRUE),

                'BUNGA_PER_BULAN' => $this->input->post('BUNGA_PER_BULAN', TRUE),

                'PERK_PIUTANG' => $this->input->post('PERK_PIUTANG', TRUE),

                'PERK_JASA' => $this->input->post('PERK_JASA', TRUE),

        );
        return $this->db->insert('info_usaha', $data);
    }

    function update($id)
    {
        $data = array(
                
                'URAIAN_USAHA' => $this->input->post('URAIAN_USAHA', TRUE),

                'MAX_CICIL' => $this->input->post('MAX_CICIL', TRUE),

                'MIN_ANGSURAN' => $this->input->post('MIN_ANGSURAN', TRUE),

                'MAX_PIUTANG' => $this->input->post('MAX_PIUTANG', TRUE),

                'BUNGA_PER_BULAN' => $this->input->post('BUNGA_PER_BULAN', TRUE),

                'PERK_PIUTANG' => $this->input->post('PERK_PIUTANG', TRUE),

                'PERK_JASA' => $this->input->post('PERK_JASA', TRUE),

        );
        $this->db->where('KODE_USAHA', $id);
        return $this->db->update('info_usaha', $data);
    }

    function delete($id)
    {
        $this->db->where('KODE_USAHA', $id);
        $this->db->delete('info_usaha');
    }

}
?>
